﻿/*************************************************
Unity 工具类
author：Daixiwei
**************************************************/
using System.Text;
using System.IO;

namespace taurus.client
{
    public static class Util
    {
     
        private static readonly string _fileDir =  "/UserData/";

        /// <summary>
        /// 写入本地数据
        /// </summary>
        /// <param name="data"></param>

        public static void SaveLocalFile(long uid,string data)
        {
            if (!Directory.Exists(_fileDir))
            {
                Directory.CreateDirectory(_fileDir);
            }
            File.WriteAllText(_fileDir+uid, data);
        }


        /// <summary>
        /// 读取本地数据
        /// </summary>
        /// <returns></returns>
        public static string LoadLocalFile(long uid)
        {
            var file = _fileDir + uid;
            if (!File.Exists(file)) return null;
            return File.ReadAllText(file);
        }

        /// <summary>
        /// 读取本地数据
        /// </summary>
        public static void ClearLocalFile(long uid)
        {
            var file = _fileDir + uid;
            if (File.Exists(file))
            {
                File.Delete(file);
            }
        }
        
    }
}